package versuch1;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {

	public static void main(String[] args) {
		int port = 13000;
		ServerSocket serverSocket = null;
		try {
			serverSocket = new ServerSocket(port);
		} catch (IOException e) {
			System.out.println("Binden an Port " + port + " schlug fehl: "
					+ e.getMessage());
			System.exit(-1);
		}
		while (true) {
			try{
		        System.out.println ("ServerSocket - accepting");
		        Socket clientSocket = serverSocket.accept();
		        
		        Thread threadHandler = new Thread(new EventHandler(clientSocket) );
		        threadHandler.start();
				
				System.out.println ("ServerSocket - Thread started, next client please...");
			}catch (IOException e) {
				System.out.println("'accept' auf Port 13000 fehlgeschlagen");
		        System.exit(-1);
			}
		}

	}
}
